import { IsString, Length, Matches, MaxLength, IsOptional } from 'class-validator';
import { Transform } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

/**
 * 提交评分任务DTO
 * 零隐患MFIS规范 - 严格输入验证
 */
export class SubmitTaskDto {
  @ApiProperty({
    description: '患者编号',
    example: 'PAT-2024-001',
    minLength: 1,
    maxLength: 50,
  })
  @IsString({ message: '患者编号必须是字符串' })
  @Length(1, 50, { message: '患者编号长度必须在1-50个字符之间' })
  @Matches(/^[A-Za-z0-9\-_]+$/, {
    message: '患者编号只能包含字母、数字、连字符和下划线'
  })
  @Transform(({ value }) => value?.trim())
  patient_code: string;

  @ApiPropertyOptional({
    description: '临床文本描述',
    example: '患者主诉腹痛，伴有便血症状',
    maxLength: 1000,
  })
  @IsString({ message: '临床文本必须是字符串' })
  @MaxLength(1000, { message: '临床文本不能超过1000个字符' })
  @IsOptional()
  @Transform(({ value }) => value?.trim())
  clinical_text?: string;
}